package crp.services.api.graphql.models;

import crp.core.portal.domain.models.PortalSectionConfig;
import crp.core.portal.domain.models.PortalSectionEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("PortalSection")
@Builder
@Getter
@AllArgsConstructor
public class PortalSectionPayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String name;
    @NotNull
    private final Integer orderNumber;
    @NotNull
    private final PortalSectionConfig config;

    public static PortalSectionPayload of(PortalSectionEntity entity) {
        return PortalSectionPayload.builder()
                .id(entity.getId())
                .name(entity.getName())
                .orderNumber(entity.getOrderNumber())
                .config(entity.getConfig())
                .build();
    }
}
